package com.mths.client.util;

import com.mths.client.component.Label;
import com.mths.client.content.MenuManager;
import com.mths.client.content.NavigationManager;
import com.mths.client.content.SpinnerManager;
import com.mths.client.page.DashboardHeader;
import com.mths.client.widget.CompanySearchWidget;

public class PageUtil {

	public static NavigationManager		navigationManager;
	public static MenuManager			menuManager;
	public static DashboardHeader		dashboardHeader;
	public static CompanySearchWidget	companySearchWidget;
	public static SpinnerManager		spinnerManager;
	public static Label					pageName	= new Label();

	public static String getPageFriendlyUrl() {
		String fullToken = getUrlPageToken();
		if (fullToken == null)
			return "";
		if (fullToken.contains("/"))
			return fullToken.substring(0, fullToken.indexOf("/"));
		else
			return fullToken;
	}

	public static String getUrlPageToken() {
		String fullUrl = getFullUrl();
		if (fullUrl.contains("#"))
			return fullUrl.substring(fullUrl.indexOf("#") + 1, fullUrl.length());
		return "";
	}

	public static native String getFullUrl() /*-{
														var s = $doc.location.href;
														return s;
														}-*/;

	public static native String jQueryAccordionPanel() /*-{
														$wnd.$("#accordionPanel").accordion({
														header: "h3",
														animate: 200,
														collapsible: true,
														heightStyle: "content"
														});
														}-*/;

}
